filetype plugin indent on

syntax enable
syntax on
"  键入 <Tab> 时使用空格
set expandtab
set smarttab
" 自动缩进宽度
set shiftwidth=4
set softtabstop=4
"  默认8
set tabstop=4
set number
set relativenumber
set cursorline
set cursorcolumn
set hlsearch
set ruler
set showcmd
set showmode
set magic
set smartindent
set encoding=utf8
set incsearch

" 消除错误声音
set novisualbell
set noerrorbells
set t_vb=
set tm=500

" 搜索忽略大小写
set ignorecase
set wildmenu
" set colorcolumn=100
set ttimeout
set ttimeoutlen=100
" 显示TAB键
"set list
"set listchars=tab:>-,trail:-



set mouse=a     " 启用鼠标支持
set autoread    " 文件从外部更改时自动读取
set autowrite   " 切换文件自动保存
set nobackup    " 备份文件
set nowritebackup
set noswapfile
" 光标上下两侧最少保留的屏幕行数
set scrolloff=2
" 换行
set nowrap
" 长行向右10个字符
set sidescroll=10
" 行首可退到上一 行，行尾可到下一行
" set whichwrap=h,l
set showcmd
set showmatch
" 底部空行
"set cmdheight=1
set laststatus=2
set updatetime=100
" 文件未保存也可以切换buffer
set hidden
set signcolumn=yes

set shortmess+=c
" 系统剪贴板和vim剪贴板公用
set clipboard+=unnamed
" backspace可以退回上一行
set backspace=indent,eol,start
" 按照缩进折叠 默认manual
" set foldmethod=indent

" 打开文件时返回到最后的编辑位置
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif

autocmd BufWritePost $MYVIMRC source $MYVIMRC

" 插入模式不高亮当前行

" 文件类型设置
autocmd InsertEnter * set nocursorline
autocmd InsertLeave * set cursorline
autocmd FileType javascript,vue,yaml set shiftwidth=2 softtabstop=2
autocmd FileType  Caddyfile set shiftwidth=8 softtabstop=8
"autocmd FileType  Caddyfile,cfg,conf set shiftwidth=4 softtabstop=4
"#autocmd BufRead,BufNewFile *.conf set filetype=python

autocmd BufEnter * set cursorline cursorcolumn

autocmd BufLeave * set nocursorline nocursorcolumn
au BufRead,BufNewFile haproxy* set ft=haproxy

" 设置光标形0
" 1 -> blinking block  闪烁的方块
" 2 -> solid block  不闪烁的方块
" 3 -> blinking underscore  闪烁的下划线
" 4 -> solid underscore  不闪烁的下划线
" 5 -> blinking vertical bar  闪烁的竖线
" 6 -> solid vertical bar  不闪烁的竖线
"let &t_EI = "\<Esc>[2 q" . "\<Esc>]12;green\x7"
"if &term =~ 'xterm' || &term == 'win32'
    " 使用 DECSCUSR 转义序列
    "let &t_SI = "\e[6 q\x7"    " 闪烁竖线
    "let &t_SR = "\e[3 q\x7"    " 闪烁下划线
    "let &t_EI = "\e[2 q\x7"    " 闪烁块状
"endif
"nnoremap <C-s> :w<CR>
"
let &t_SI = "\e[5 q"
let &t_EI = "\e[2 q"
let &t_SR = "\e[4 q"
let &t_EI = "\e[2 q"

augroup CursorShape
  autocmd!
  autocmd InsertEnter * silent! let &t_SI = "\e[5 q"
  autocmd InsertLeave * silent! let &t_EI = "\e[2 q"
augroup END
